<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			function jiecheng(){
				var int1 = parseInt(document.getElementById("input1").value);
				var int2 = document.getElementById("input2");
				var num=1;
			if(int1<0){
				alert("负数没有阶乘");/*添加一个提示框*/
			}else if (int1==0){
				int2.innerHTML=1;
				}else{
					for(var i=2;i<=int1;i++){
						num=num*i;
					}
					int2.innerHTML=num;
				}
			}
		</script>
	</head>
	<body>
		<table>
			<tr>
				<td>请输入一个整数</td>
				<td>
					<input id="input1" type="text"  value=" "/>
				</td>
				<td>
					<input type="button" onclick="jiecheng()" value="阶乘" />
				</td>
				<td>=</td>
				<td>
					<span id="input2"/>
				</td>
			</tr>
		</table>
	</body>
</html>
